<%@page pageEncoding="UTF-8"%>
<%@page import="jp.dodododo.aop.config.AspectConfigVisualization" %>
<%@page import="jp.dodododo.aop.config.AspectDef" %>
<%@page import="jp.dodododo.aop.Pointcut" %>
<%@page import="java.util.List" %>
<%@page import="java.lang.reflect.AccessibleObject" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>samurai-aop</title>
</head>
<body>
<form action="samurai-aop.jsp" method="POST">
<%
request.setCharacterEncoding("UTF-8");
String className = request.getParameter("className");
if(className == null || className.length() == 0) {
	className = "";
}
String methodName = request.getParameter("methodName");
if(methodName == null || methodName.length() == 0) {
	methodName = "";
}
System.out.println(className);
%>

ClassName<input name="className" value="<%out.print(className);%>" />
<br>
MethodName<input name="methodName" value="<%out.print(methodName);%>" />
<br>
<input type="submit" />
<hr />

<%
if(0 < className.length()) {
	ClassLoader cl = getClass().getClassLoader();
	while(cl != null) {
		out.println("<h4>");
		out.println(cl);
		out.println("</h4>");

		out.println("<table border=\"1\">");
		List<AspectDef> aspectDefList = AspectConfigVisualization.getAspectDefList(cl, className, methodName);
		for (AspectDef aspectDef : aspectDefList) {
			AccessibleObject staticPart = aspectDef.getStaticPart();
			out.println("<tr>");
			out.println("<td>");
			out.println(staticPart);
			out.println("</td>");
			out.println("<td>");
			out.println("<br />");
			out.println("</td>");
			out.println("</tr>");
			List<Pointcut> pointcutList = aspectDef.getPointcutList();
			for (Pointcut pointcut : pointcutList) {
				out.println("<tr>");
				out.println("<td>");
				out.println("<br />");
				out.println("</td>");
				out.println("<td>");
				out.print(pointcut.getInterceptorStatement());
				out.println("</td>");
				out.println("</tr>");
			}
		}

		out.println("</table>");
		out.println("<hr />");
		cl = cl.getParent();
	}
}
%>

</form>
</body>
</html>